<template>
	<view>
	<view> 踩坑注意：$store.state.state</view>
	 全局计算器	{{ count }}
	 <view> 双倍 {{ doubleCount }}</view>
	 <u-search placeholder="请输入商品" v-model="keyword"></u-search>
	 <view class="title">
		<view>商品</view>
		<view>操作</view>
	 </view>
	 <view class="content">
		<view>手机</view>
		<view>
			<u-number-box></u-number-box>
		</view>
	 </view>
	 <!-- <button @click="btnClick">点击count加1</button>
	 <button @click="asyncClick">点击异步加2</button> -->
	 <button @click="add(1)">点击count加1</button>
	 <button @click="asyncAdd(2)">点击异步加2</button>
	</view>
</template>

<script>
import { mapState ,mapGetters ,mapMutations,mapActions} from 'vuex'


	export default {
		data() {
			return {
				keyword:''
			}
		},
		onLoad(options) {
			console.log(this.$store.state.count)
		},
		computed:{
			...mapState({
				count:state=>state.count,
			}),
			// count(){
			// 	return this.$store.state.count
			// },
			// doubleCount(){
			// 	return this.$store.getters.doubleCount
			// }
			...mapGetters(['doubleCount'])
		},
		methods: {
			btnClick(){
				this.$store.commit('add',1)
			},
			asyncClick(){
				console.log('----点击加2')
				this.$store.dispatch('asyncAdd',2)
			},
			...mapMutations(['add']),
			...mapActions(['asyncAdd'])
		}
	}
</script>

<style>

</style>
